Product Code Database
Example Keywords: smartphones -slippers $80-186
barcode-scavenger
   » » Wiki: Path (computing)
Tag Wiki 'Path (computing)'.
Tag

A path (or filepath, file path, pathname, or similar) is a text string that uniquely specifies an item in a hierarchical file system. Generally, a path is composed of directory names, special directory specifiers and optionally a , separated by . The delimiter varies by operating system and in theory can be anything, but popular, modern systems use slash , , or colon .

A path can be either relative or absolute. A relative path includes information that is relative to a particular directory whereas an absolute path indicates a location relative to the system , and therefore, does not depends on context like a relative path does. Often, a relative path is relative to the working directory. For example, in command , is a relative path to the file with that name in the working directory.

Paths are used extensively in to represent the directory/file relationships common in modern operating systems and are essential in the construction of uniform resource locators (URLs).


History
first introduced a hierarchical file system with directories (separated by ">") in the mid-1960s.

Around 1970, introduced the slash character ("/") as its directory separator.

Originally, did not support directories, but when adding the feature, using the Unix standard of slash was not a good option since many existing commands used slash as the switch prefix. For example, dir /w. In contrast, Unix uses dash as the switch prefix. In this context, MS-DOS version 2.0 used backslash for the path delimiter since it is similar to slash but did not conflict with existing commands. This convention continued into in its shell . Eventually, , was introduced to Windows that is slash-agnostic, allowing the use of either slash in a path.


Path syntax
The following table describes the syntax of paths in notable operating systems and with notable aspects by shell.

Japanese and Korean versions of Windows often display the '¥' character or the '' character instead of the directory separator. In such cases the code for a backslash is being drawn as these characters. Very early versions of MS-DOS replaced the backslash with these glyphs on the display to make it possible to display them by programs that only understood 7-bit (other characters such as the square brackets were replaced as well, see ISO 646, Windows Codepage 932 (Japanese Shift JIS), and Codepage 949 (Korean)). Although even the first version of Windows supported the 8-bit ISO-8859-1 character set which has the Yen sign at U+00A5, and modern versions of Windows supports which has the Won sign at U+20A9, much software will continue to display backslashes found in ASCII files this way to preserve backward compatibility.

, as a derivative of UNIX, uses UNIX paths internally. However, to preserve compatibility for software and familiarity for users, many portions of the GUI switch "/" typed by the user to ":" internally, and switch them back when displaying filenames (a ":" entered by the user is also changed into "/" but the inverse translation does not happen).


Paths in programming languages
Programming languages also use paths. E.g.: When a file is opened. Most programming languages use the path representation of the underlying operating system:

 /
     

 /
     

This direct access to the operating system paths can hinder the portability of programs. To support portable programs Java uses File.separator to distinguish between / and \ separated paths. Seed7 has a different approach for the path representation. In Seed7 all paths use the Unix path convention, independent of the operating system. Under windows a mapping takes place (e.g.: The path /c/users is mapped to c:\users).


Universal Naming Convention
The Microsoft universal naming convention ( UNC), a.k.a. uniform naming convention, a.k.a. network path, specifies a syntax to describe the location of a network resource, such as a shared file, directory, or printer. A UNC path has the general form:

\\ComputerName\SharedFolder\Resource
     

Some Windows interfaces allow or require UNC syntax for share access, rather than a URL. The UNC syntax is extended with optional components to denote use of SSL and TCP/IP port number, a WebDAV URL of . becomes

\\HostName[@SSL][@Port]\SharedFolder\Resource
     

When viewed remotely, the "SharedFolder" may have a name different from what a program on the server sees when opening "\SharedFolder". Instead, the SharedFolder name consists of an arbitrary name assigned to the folder when defining its "sharing".

Some Windows interfaces also accept the "Long UNC":

\\?\UNC\ComputerName\SharedFolder\Resource
     

Windows uses the following types of paths:

  • local file system (LFS), such as ..
  • universal naming convention (UNC), such as ~ or //home/user/docs/Letter.txt (at least in Windows 7 and later)
  • "long" device path such as ./inthisdir or ../../greatgrandparent. This path points to the local file namespace and is a similar one that points to the local DOS device namespace. This format is also the "raw" or "uninterpreted" path, since it sends paths straight to the file system without converting to and interpreting names like .
  • Windows NT object manager ~/.rcinfo-prefixed paths (global DOS namespace).

In versions of Windows prior to Windows XP, only the APIs that accept "long" device paths could accept more than 260 characters.

The in and , explorer.exe, allows path names up to 248 characters long.

Since UNCs start with two backslashes, and the backslash is also used for string escaping and in regular expressions, this can result in extreme cases of leaning toothpick syndrome: an escaped string for a regular expression matching a UNC begins with 8 backslashes – ''[drive letter:]''\ – because the string and regular expression both require escaping. This can be simplified by using , as in C#'s \\''[server name]''\''[volume]''\ or Python's \, or regular expression literals, as in Perl's ..


POSIX pathname definition
Most Unix-like systems use a similar syntax. allows treating a path beginning with two slashes in an implementation-defined manner, though in other cases systems must treat multiple slashes as single slashes. Many applications on Unix-like systems (for example, , rcp, and ) use resource definitions such as:

hostname:/directorypath/resource
     

or URI schemes with the service name (here 'smb'):

smb://hostname/directorypath/resource
     


Examples

Unix
The following examples are for typical, Unix-based file systems:

Given the working directory is and it contains subdirectory , relative paths to the subdirectory include and , and the absolute path is . A command to change the working directory to the subdirectory:


Microsoft shells
The accepts slash for path delimiter.

Unlike Unix that always has a single root directory, a Windows file system has a root for each storage drive. An absolute path includes a drive letter or uses the UNC format.

A UNC path (starting with ) does not support slashes.

.. is an absolute path that specifies a file named in the directory which is in the root of drive :

C:\USER\DOCS\LETTER.TXT is a relative path that specifies file located in the parent of the working directory on drive :

A:PICTURE.JPG is a relative path that specifies file in directory which is in directory which is in the working directory of the current drive:

\\SERVER01\USER\DOCS\LETTER.TXT is a relative path that specifies ''[drive letter:]''\ in the working directory:

\\''[server name]''\''[volume]''\ specifies the first , COM1:

The following uses a path with slashes for directory delimiter:

C:\>more < C:/Windows/system.ini

for 16-bit app support
386Enh woafont=dosapp.fon EGA80WOA.FON=EGA80WOA.FON EGA40WOA.FON=EGA40WOA.FON CGA80WOA.FON=CGA80WOA.FON CGA40WOA.FON=CGA40WOA.FON ...

A path with forward slashes may need to be surrounded by double quotes to disambiguate from command-line switches. For example, is invalid, but is valid. And is more lenient by allowing .


See also

External links

Page 1 of 1
1
Page 1 of 1
1

Account

Social:
Pages:  ..   .. 
Items:  .. 

Navigation

General: Atom Feed Atom Feed  .. 
Help:  ..   .. 
Category:  ..   .. 
Media:  ..   .. 
Posts:  ..   ..   .. 

Statistics

Page:  .. 
Summary:  .. 
1 Tags
10/10 Page Rank
5 Page Refs
1s Time